package mobileapps.examples;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.*;


public class P02RadioButtonWithToast extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
		Log.i("P02", "Radio button not yet selected :");
		  final RadioButton r1 = (RadioButton) findViewById(R.id.radio1);
		  final RadioButton r2 = (RadioButton) findViewById(R.id.radio2);
		  final RadioButton r3 = (RadioButton) findViewById(R.id.radio3);
		  final RadioButton r4 = (RadioButton) findViewById(R.id.radio4);
		  r1.setOnClickListener(radio_listener);
		  r2.setOnClickListener(radio_listener); 
		  r3.setOnClickListener(radio_listener);
		  r4.setOnClickListener(radio_listener);
    }
   
    private OnClickListener radio_listener = new OnClickListener() {
        public void onClick(View v) {
            // Perform action on clicks
            RadioButton rb = (RadioButton) v;
        	Toast.makeText(P02RadioButtonWithToast.this, rb.getText(), Toast.LENGTH_LONG).show();
            rb.setText("Text has been reset!");
        	Log.i("P02", "Radio button selected :");
        }
    }; 
}

